]> dgit.raspbian.org Git - ostree.git/commit
ostree-sign-ed25519: Fix overwriting already-set GErrors
authorPhilip Withnall <pwithnall@gnome.org>
Mon, 3 Aug 2026 15:31:46 +0000 (16:31 +0100)
committerPhilip Withnall <pwithnall@gnome.org>
Tue, 4 Aug 2026 12:10:18 +0000 (13:10 +0100)
commit5a529c3dcab310ed8c5b1114cfb7237176b4481c
treeb724848e2d8ee46aadbdb178b84c91029c514d95
parent82d76f002a55163527cefcd8e7e964fa3cc62e7a
ostree-sign-ed25519: Fix overwriting already-set GErrors

There were a couple of issues here, related to passing a `GError**` into
a sub-function inside a loop:
 - If multiple calls inside the loop failed (e.g. if multiple keys
   inside the file were invalid, because it was a malformed file), the
   `GError` would be overwritten and cause a critical warning from GLib.
 - If an early iteration failed, but then subsequent ones succeeded, the
   `_load_pk_from_stream()` function would return `TRUE` but would also
   set its `GError`, which is a very non-standard (basically prohibited)
   thing to do with a `GError` argument.

Fix that by using a `first_error` variable internally and only
propagating it to the caller on failure.

This can be reproduced by trying to verify a signature using a key file
which isn’t actually a key file:
```
ostree sign --verify --repo ./my-repo $commit_id \
  --keys-file ./test.published.gpg
```

The keys file is expected to be in a custom format, with one ed25519 key
per line. An ASCII-armoured GPG keyring is not that format, and causes
it to go big boom.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
src/libostree/ostree-sign-ed25519.c